package com.example.environment.inject;

import com.example.environment.inject.config.AutoConfigTest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ImportResource;

/**
 * @author yanzhao
 * @date 2022/5/28 14:14
 * @since 1.0.0
 */
@SpringBootApplication
@ImportResource("classpath:access-config.xml")
public class EnvironmentAutoInjectDemo {

    public static void main(String[] args) {

        ConfigurableApplicationContext run = SpringApplication.run(EnvironmentAutoInjectDemo.class, args);

        // AutoConfigTest 自动配置的类，自动将手动注入到 Environment 中的环境变量注入到配置类
        AutoConfigTest bean = run.getBean(AutoConfigTest.class);

        System.out.println(bean);

        run.close();
    }
}
